;;; -*- Mode:LISP; Package:USER; Base:10 -*-


;;; For input, define :NEXT-INPUT-BUFFER &OPTIONAL NO-HANG-P => ARRAY START END
;;;                   :DISCARD-INPUT-BUFFER ARRAY
;;; For output, define :NEW-OUTPUT-BUFFER => ARRAY START END
;;;                    :SEND-OUTPUT-BUFFER ARRAY END
;;;                    :DISCARD-OUTPUT-BUFFER ARRAY


(DEFFLAVOR MY-TEST-STREAM
           ((KOUNT 3))
           (SI:BUFFERED-INPUT-STREAM))

(DEFVAR *X* "FOOBAR ")

(DEFMETHOD (MY-TEST-STREAM :NEXT-INPUT-BUFFER) (&OPTIONAL IGNORE)
  (COND ((ZEROP KOUNT)
         NIL)
        ('ELSE
         (DECF KOUNT)
         (FORMAT T "~&ALLOCATING AT KOUNT = ~D~%" KOUNT)
         (VALUES *X* 0 (LENGTH *X*)))))

(DEFMETHOD (MY-TEST-STREAM :DISCARD-INPUT-BUFFER) (&OPTIONAL IGNORE)
  (FORMAT T "~&DISCARDING AT KOUNT = ~D~%" KOUNT))


(COMPILE-FLAVOR-METHODS MY-TEST-STREAM)
